package com.dibang.app.operation.control.impl;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.EditText;

import com.dibang.app.MainActivity;
import com.dibang.app.R;
import com.dibang.app.mvp.abs.AbsControl;
import com.dibang.app.operation.control.abs.LoginControl;
import com.dibang.app.operation.model.abs.LoginModel;
import com.dibang.app.operation.presenter.abs.LoginPresenter;
import com.dibang.app.operation.provider.LoginProImpl;
import com.dibang.app.operation.view.abs.LoginView;
import com.dibang.app.ui.LoginSmsMobileActivity;
import com.dibang.app.view.AppKeyBoardUtil;
import com.dibang.app.view.ViewHelper;
import com.dx.dxloadingbutton.lib.LoadingButton;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by wxl on 2019/7/16.
 *
 */

public class LoginControlImpl extends AbsControl<LoginView,LoginPresenter,LoginModel,LoginProImpl>implements LoginControl {

    @BindView(R.id.login_btn)
    LoadingButton button;

    @BindView(R.id.login_input_account_view)
    EditText accountView;

    @BindView(R.id.login_input_pwd_view)
    EditText pwdView;


    public LoginControlImpl(@NonNull View targetView) {
        super(targetView);
        ButterKnife.bind(this,targetView);
        ViewHelper.setLoadingButtonBackgroundShader(button);
    }

    @OnClick(R.id.login_btn)
    public void onLoginClick(View v){
//        button.setRippleEnable(false);
//        button.startLoading();
        getContext().startActivity(new Intent(getContext(), MainActivity.class));
    }


    @OnClick(R.id.activity_menu_id)
    public void onMenuViewClick(View v){
        hideKeybord();
        getContext().startActivity(new Intent(getContext(), LoginSmsMobileActivity.class));
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        hideKeybord();
    }

    /**
     * 隐藏输入法
     */
    private void hideKeybord(){
        AppKeyBoardUtil.hideKeybord(accountView);
        AppKeyBoardUtil.hideKeybord(pwdView);
    }
}
